#!/usr/bin/env perl

use strict;
use warnings;
use utf8;
use Data::Dumper;

$/ ="";

my $suite_name;
my $line;
my $get = "FAIL";
my %suites;
my $fails = {};

while(<>) {
    if(/== Entering suite.*"(.*)" ==/) {
        if(defined $suite_name) {
            $suites{$suite_name} = $fails;
            $fails = {};
        }

        $suite_name = $1;
        next;
    }

    /$get\W+/ or next;

    /Line:\s+(.*)/;

    #print "$1: $_\n";

    $fails->{$1} = $_ unless defined $fails->{$1};
}

#print Dumper(%suites);

foreach my $okey (sort keys %suites) {
    my $fails = $suites{$okey};
    print "###############################################################################\n";
    print "# $okey\n";
    print "###############################################################################\n";
    unless(%$fails) {
        print "No failures\n\n";
        next;
    }
    foreach my $ikey (keys %$fails) {
        print "$fails->{$ikey}\n";
    }
}

